<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>元素的显示/隐藏</title>
</head>
<body>
<div id="change" class="change">
    <h1 data-show="status" style="background-color: red">Hello, World!</h1>
    <h1 data-show="!status" style="background-color: silver">Hello, World!</h1>
</div>

<script>
    let status = true

    let elements = document.querySelectorAll("#change > h1");

    for (let i = 0; i < elements.length; i++) {
        // console.log(elements[i]);

        let attribute = elements[i].getAttribute("data-show");

        // console.log(attribute);

        // console.log(typeof eval(attribute));

        if (eval(attribute) === false) {
            elements[i].style.display = "none"
        }
    }
</script>
</body>
</html>